package com.hk.welcome;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hk.action.Action;
import com.hk.action.ActionForward;
import com.hk.dtos.AdminDto;
import com.hk.dtos.BBSDto;
import com.hk.service.BBSService;
import com.hk.service.LoginService;

public class AnswerGoAction  implements Action{
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
	BBSService manager=BBSService.getInstance();
	BBSDto dto = new BBSDto();
	
	String tref = request.getParameter("ref");
	String tdepth = request.getParameter("depth");
	String tstep = request.getParameter("step");
	String tseq = request.getParameter("seq");
	
    int ref = Integer.parseInt(tref);
    int depth = Integer.parseInt(tdepth);
    int step = Integer.parseInt(tstep);
    int seq = Integer.parseInt(tseq);
    
	String id = request.getParameter("id");
    String content = request.getParameter("content");
    String title = request.getParameter("title");
    String pwd = request.getParameter("pwd");
    
    dto.setSeq(seq);
    dto.setParent(seq);
    dto.setStep(step);
    dto.setRef(ref);
    dto.setDepth(depth);
    dto.setId(id);
    dto.setContent(content);
    dto.setTitle(title);
    dto.setPwd(pwd);
    manager.re_insBoard(dto);
    
////////////////////////////////////////////
	LoginService ls= LoginService.getInstance();
		
	ArrayList<AdminDto> ad = ls.getmenu();
	
	AdminDto tad1 = new AdminDto();
	AdminDto tad2 = new AdminDto();
	AdminDto tad3 = new AdminDto();
	AdminDto tad4 = new AdminDto();
	AdminDto tad5 = new AdminDto();
	
	AdminDto tad6 = new AdminDto();
	AdminDto tad7 = new AdminDto();
	AdminDto tad8 = new AdminDto();
	AdminDto tad9 = new AdminDto();
	AdminDto tad10 = new AdminDto();
	AdminDto tad11 = new AdminDto();
	
	tad1=ad.get(0);
	tad2=ad.get(1);
	tad3=ad.get(2);
	tad4=ad.get(3);
	tad5=ad.get(4);
	
	tad6=ad.get(5);
	tad7=ad.get(6);
	tad8=ad.get(7);
	tad9=ad.get(8);
	tad10=ad.get(9);
	tad11=ad.get(10);
			
	request.setAttribute("menu1",tad1);
	request.setAttribute("menu2",tad2);
	request.setAttribute("menu3",tad3);
	request.setAttribute("menu4",tad4);
	request.setAttribute("menu5",tad5);
	
	request.setAttribute("leftmenu1",tad6);
	request.setAttribute("leftmenu2",tad7);
	request.setAttribute("leftmenu3",tad8);
	request.setAttribute("leftmenu4",tad9);
	request.setAttribute("leftmenu5",tad10);
	request.setAttribute("leftmenu6",tad11);
	////////////////////////////////////////////
	
	ActionForward forword=new ActionForward();
	
	forword.setUrl("list");
	forword.setRedirect(false);

	return forword;
}//
}
